/*
 * @Author: lusx 
 * @Date: 2020-03-12 17:10:05 
 * @Last Modified by: lusx
 * @Last Modified time: 2020-04-20 17:01:46
 */
import { Button } from 'antd';
import { WeaLocaleProvider } from 'ecCom';
import _ from 'lodash';
const getLabel = WeaLocaleProvider.getLabel;
import { objDocument, objFlow, objCustomer, objProject, objTask, upload, toolbarfun } from './configUtil';
const ckConfig = (visibleDialog) => {
    const height = visibleDialog ? (window.screen.width>=1920?600 - 31:400 - 31) : 50;
    const autoGrow_minHeight = visibleDialog ? (window.screen.width>=1920?600 - 31:400 - 31) : 150;
    const autoGrow_maxHeight = visibleDialog ? (window.screen.width>=1920?600 - 31:400 - 31) : 160;
    const toolbar = toolbarfun(visibleDialog);
    return {
        toolbar: toolbar,
        extraPlugins: 'autogrow',
        height: height,
        autoGrow_minHeight: autoGrow_minHeight,
        autoGrow_maxHeight: autoGrow_maxHeight,
        removePlugins: 'resize',
        uploadUrl: '/api/doc/upload/uploadFile?model=reply',
    }
}
const bottomBarRight = (submitfun, loading="false",fun) => {
    return {
        Component: <div>
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@wr2o3d`}
                key="submit"
                type="primary"
                style={{ display: 'inline-block', borderRadius: '3px', marginTop: '5px', paddingRight: '7px' }}
                onClick={() => { submitfun('create'); fun(false) }}
                size="small"
                loading = {loading}
                >
                {getLabel(383336, "提交")}
            </Button>
            <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@sc2bbq`}
                key="cancel"
                type="primary"
                size="small"
                style={{ display: 'inline-block', marginLeft: '5px', borderRadius: '3px', marginTop: '5px' }}
                onClick={() => {
                    fun(false)
                }} >
                {getLabel(31129, "取消")}
            </Button>
        </div>
    }

};
const bottomBarConfig = (params, fun) => {
    const { exchangeList = {}, type } = params;
    const barConfig1 = [{
        name: 'Component',
        show: <span className="full-screen-link" onClick={fun}>{getLabel('518320','全屏编辑')}</span>,
    }];
    let barConfig2 = [];
    if (Object.keys(exchangeList).length > 0) {
        exchangeList.docids && barConfig2.push(objDocument);//相关文档
        exchangeList.relatedwf && barConfig2.push(objFlow);//相关流程
        exchangeList.relatedcus && barConfig2.push(objCustomer);//相关客户
        exchangeList.projectids && barConfig2.push(objProject);//相关项目
        exchangeList.relatedprj && barConfig2.push(objTask);//相关任务
        exchangeList.relateddoc && barConfig2.push(upload({ exchangeList }));
    }
    return _.get({
        'simple': barConfig1,
        'complex': barConfig2
    }, type)
}
export {
    ckConfig,
    bottomBarRight,
    bottomBarConfig
}